{include file='public/head'}
<body>
<table class="layui-hide" id="test" lay-filter="test"></table>


<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">分配管家</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">分配管理员</a>
</script>


<script src="/static/layui/dist/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#test'
            ,url:'/admin/customer/matchCustomer?page=1&limit=10'
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,title: '用户数据表'
            ,cols: [[
                {templet: '#indexTpl', title:'序号', fixed: 'left', unresize: true,align:'center'}
                ,{field:'id', title:'id',  fixed: 'left', unresize: true, sort: true,align:"center",hide:true}
                ,{field:'name', title:'用户名', edit: 'text',align:"center"}
                ,{field:'state', title:'状态', edit: 'text', sort: true,align:"center"}
                ,{field:'login_time', title:'登录时间',align:"center"}
                ,{field:'username', title:'用户名',align:"center"}
                ,{field:'head', title:'头像',align:"center",templet:'<div><img src="{{d.head}}" style="height: 100%;width: 100%;"></div>'}
                ,{field:'guan_jia_id', title:'管家id',align:"center",hide:true}
                ,{field:'guan_jia_username', title:'管家名字',align:"center"}
                ,{field:'admin_id', title:'管理员id',align:"center",hide:true}
                ,{field:'admin_useranme', title:'管理员名字',align:"center"}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo',align:"center",width:240}
            ]]
            ,page: true
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            console.log(data)
            if(obj.event === 'del'){
                x_admin_show('分配管理员','getGuanLiYuanAll?id='+data['id']+'&gly_id='+data['admin_id'],500,410);
            } else if(obj.event === 'edit'){
                x_admin_show('分配管家','getGuanJiaAll?id='+data['id']+'&gj_id='+data['guan_jia_id'],500,410);
            }
        });
    });
</script>
<script type="text/html" id="indexTpl">
    {{d.LAY_TABLE_INDEX+1}}
</script>
</body>

</html>